﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NHibernate;
using TKToXML.Persistence;
using NHibernate.Cfg;
using NHibernate.Tool.hbm2ddl;

namespace Test.Persistence.Repositories
{
    public class RepositoryTestBase
    {
        protected ISession session;

        public void setup()
        {
            NHibernateConfiguration.Initialize("TestEcustoms", RebuildDatabase());

            //NHibernateConfiguration.Init(
            //    MsSqlConfiguration.MsSql2008.ConnectionString(
            //    builder => builder.Server("localhost")
            //        .Database("TestEcustoms").TrustedConnection()),
            //        RebuildDatabase());

            session = NHibernateConfiguration.CreateAndOpenSession();
        }

        private Action<Configuration> RebuildDatabase()
        {
            //return config => new SchemaExport(config).Create(false, true);
            return config => new SchemaUpdate(config).Execute(false, true);
        }
    }
}